using System;
using System.Data;
using System.Windows;
using DevExpress.Xpf.Charts;

namespace NeuroForecast
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            // Create a line series.
            // Series series1 = new Series("Series 1", ViewType.Line);
            LineSeries2D ls2d = new LineSeries2D();
            LineSeries2D ls1d = new LineSeries2D();
            LineSeries2D lsres= new LineSeries2D();
            
            // Add points to it.

            var results = from myRow in SData.AsEnumerable()
                          where Convert.ToDateTime(myRow.ItemArray[0]) > new DateTime(2010, 12, 01) && 
                                Convert.ToDateTime(myRow.ItemArray[0]) < new DateTime(2011, 01, 10)
                          orderby myRow[0]
                          select myRow;

            foreach (var row in results)
            {
                ls2d.Points.Add( new SeriesPoint(Convert.ToDateTime(row[0]), Convert.ToDouble(row[1])));
                ls1d.Points.Add(new SeriesPoint(Convert.ToDateTime(row[0]), Convert.ToDouble(row[2])));
            }

            foreach (var row in RData.AsEnumerable())
            {
                lsres.Points.Add(new SeriesPoint(Convert.ToDateTime(row[0]), Convert.ToDouble(row[1])));
            }

            ls2d.MarkerVisible = false;
            ls2d.ArgumentScaleType = ScaleType.DateTime;
            ls2d.Label = new SeriesLabel();
            ls2d.Label.Visibility = Visibility.Collapsed;
            ls2d.Label.ConnectorVisible = false;

            ls1d.MarkerVisible = false;
            ls1d.ArgumentScaleType = ScaleType.DateTime;
            ls1d.Label = new SeriesLabel();
            ls1d.Label.Visibility = Visibility.Collapsed;
            ls1d.Label.ConnectorVisible = false;

            lsres.MarkerVisible = false;
            lsres.ArgumentScaleType = ScaleType.DateTime;
            lsres.Label = new SeriesLabel();
            lsres.Label.Visibility = Visibility.Collapsed;
            lsres.Label.ConnectorVisible = false;

            //XYDiagram2D diagram = ((XYDiagram2D) chartControl1.Diagram);
            //diagram.AxisX.Range = new AxisRange();
            //diagram.AxisX.Range.MaxValue = new DateTime(2011, 04, 20);
            //diagram.AxisX.Range.MinValue = new DateTime(2011, 01, 20);

            //ls2.
            // Add the series to the chart.
            chartControl1.Diagram.Series.Add(ls2d);
            chartControl1.Diagram.Series.Add(ls1d);
            chartControl1.Diagram.Series.Add(lsres);
            //ls2.MarkerVisible = false;



        }
    }
}